package com.zhuiYun.project.api.menu.controller;

import com.zhuiYun.project.annotation.OptLog;
import com.zhuiYun.project.api.menu.model.MenuModel;
import com.zhuiYun.project.api.menu.service.MenuService;
import com.zhuiYun.project.api.sysUser.model.SysUserModel;
import com.zhuiYun.project.common.controller.BaseController;
import com.zhuiYun.project.common.errorCode.CommonException;
import com.zhuiYun.project.common.response.CommonConstants;
import com.zhuiYun.project.common.response.CommonResult;
import com.zhuiYun.project.util.pageUtil.PageRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.server.Session;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**菜单模块
 * @Author dongdong
 * @Date 2023/4/3 19:52
 **/
@RestController
@RequestMapping("/menu")
@Api(tags = "菜单模块")
@Slf4j
public class MenuController  {
    @Autowired
    MenuService menuService;
    /**
     * @description:根据用户查询菜单
     * @author: dongdong
     * @date: 2023/4/3 20:01
     * @param:
     * @return: com.zhuiYun.project.common.response.CommonResult
     **/
    @GetMapping("/getMenuByUser")
    @ApiOperation(value = "根据用户查询菜单")
    @OptLog(modular = "菜单管理", type = CommonConstants.SELECT, describe = "根据用户查询菜单")
    public CommonResult getMenuByUser()  {
        return menuService.getMenuByUser();
    }
    /**
     * @description:菜单管理的分页查询方法
     * @author: dongdong
     * @date: 2023/4/3 20:01
     * @param:
     * @return: com.zhuiYun.project.common.response.CommonResult
    **/
    @GetMapping("/getMenuAndFunction")
    @ApiOperation(value = "查询菜单以及功能")
    @OptLog(modular = "菜单管理", type = CommonConstants.SELECT, describe = "查询")
    public CommonResult getMenuAndFunction()  {
        return menuService.getMenuAndFunction();
    }
    /**
     * @description:查询没有功能的菜单
     * @author: dongdong
     * @date: 2023/4/3 20:01
     * @param:
     * @return: com.zhuiYun.project.common.response.CommonResult
     **/
    @GetMapping("/getMenuNotFunction")
    @ApiOperation(value = "查询没有功能的菜单")
    @OptLog(modular = "菜单管理", type = CommonConstants.SELECT, describe = "查询")
    public CommonResult getMenuNotFunction()  {
        return menuService.getMenuNotFunction();
    }
    /**
     * @description: 菜单新增
     * @author: dongdong
     * @date: 2023/4/4 10:26
     * @param: [menuModel]
     * @return: com.zhuiYun.project.common.response.CommonResult
    **/
    @PostMapping("/saveMenu")
    @ApiOperation(value = "菜单管理的新增方法")
    @OptLog(modular = "菜单管理", type = CommonConstants.ADD, describe = "新增菜单")
    public CommonResult saveMenu(@RequestBody MenuModel menuModel) throws CommonException {
        log.info("新增菜单menuModel:"+menuModel);
        return menuService.saveMenu(menuModel);
    }
    /**
     * @description: 删除菜单页
     * @author: dongdong
     * @date: 2023/4/5 20:00
     * @param: [id]
     * @return: com.zhuiYun.project.common.response.CommonResult
    **/
    @DeleteMapping("/delMenuById")
    @ApiOperation(value = "菜单管理的删除方法")
    @OptLog(modular = "菜单管理", type = CommonConstants.DELETE, describe = "删除菜单")
    public CommonResult delMenuById(Integer id) throws CommonException {
        log.info("删除菜单信息");
        return menuService.delMenuById(id);
    }
    /**
     * @description: 修改菜单
     * @author: dongdong
     * @date: 2023/4/5 20:02
     * @param: [sysUserModel]
     * @return: com.zhuiYun.project.common.response.CommonResult
    **/
    @PutMapping("/updateMenu")
    @ApiOperation(value = "菜单管理的修改方法")
    @OptLog(modular = "菜单管理", type = CommonConstants.UPDATE, describe = "修改菜单")
    public CommonResult updateMenu(@RequestBody MenuModel menuModel) throws CommonException {
        log.info("修改菜单");
        return menuService.updateMenu(menuModel);
    }

}
